package com.future.mayi.jpush;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.future.mayi.activity.ActivitiesActivity;
import com.future.mayi.activity.AppraisalOrderActivity;
import com.future.mayi.activity.GoodsActivity;
import com.future.mayi.activity.GoodsOrderActivity;
import com.future.mayi.activity.MsgDetailActivity;
import com.future.mayi.activity.RecycleOrderActivity;
import com.future.mayi.activity.SystemMessageActivity;
import com.future.mayi.activity.WebActivity;
import com.future.mayi.app.App;
import com.future.mayi.model.SystemNotificationModel;


/**
 * Created by Administrator on 2018/3/8.
 */

public class Navigator {

    /**
     * 获取通知具体跳转的intent
     *
     * @param extraMsg
     * @return
     */
    public static Intent getNotificationListIntent(Context context, String extraMsg) {
        Intent intent = null;
        if ((!TextUtils.isEmpty(extraMsg)) && (!extraMsg.equals("{}"))) {
            SystemNotificationModel model = App.getGson().fromJson(extraMsg, SystemNotificationModel.class);
            if (model != null) {
                if (model.getJump_type() == 0) {
                     intent = new Intent(context, MsgDetailActivity.class).putExtra("msgId", model.getRelation_id());
                } else if (model.getJump_type() == 1) {
                    intent = new Intent(context, GoodsActivity.class).putExtra("goodsId", model.getRelation_id());
                } else if (model.getJump_type() == 2) {
                    intent = new Intent(context, ActivitiesActivity.class).putExtra("activity_id", model.getRelation_id());
                } else if (model.getJump_type() == 3) {
                    intent = new Intent(context, GoodsOrderActivity.class).putExtra("orderId", model.getRelation_id());
                }
            }
        } else intent = new Intent(context, SystemMessageActivity.class);
        return intent;
    }


}
